import DB from 'db';
import { Dialog } from 'saltui';
let meetingAddressFlag = 1;

export default{
  //处理参数
  dealwithCommonParam:function(param,props){
    param.boardroomId = props.location.query.boardRoomId;
    param.startTime = props.location.query.startTime;
    param.endTime = props.location.query.endTime;
    return param;
  },
  //处理查询流程数据
  dealwithCommonFolowInfo:function(param,data,sucessFunc,failureFuc){
    param.boardroomId = data.boardroomId;
    param.startTime = data.startTime;
    param.endTime = data.endTime;
    param.title = data.title;
    DB.SomeModuleAPI.getMeetingRoomBpmInfo(param).then((content) => {
      //去掉会议模板按钮
      content.buttons=content.buttons.replace(",MEETING_MODEL","").replace("MEETING_MODEL,","").replace("MEETING_MODEL","")
      sucessFunc(content);
    }).catch((error) => {
      failureFuc(error);//没有待办权限
    });
  },
  //处理按钮
  /*dealwithCommonButton:function(param,sucessFunc,failureFuc){

  },*/
  //保存前验证(0-提交，1-保存)
  saveBefore:function(type,param,sucessFunc,failureFuc){
    var formData;
    if(type == "0"){
      formData = param.editFormData;
    }else {
      formData = param.formData;
    }
    
    //提交表单前检查预约会议室表单
    if(formData!=null && formData!=undefined) {
      if(type == "1"){
        formData = JSON.parse(formData);
      }
      var id = "";
      if(formData.dataId != null){
        id = formData.dataId;
      }
      var mainTblData = formData.mainTblData;
      var name = "",meetingTypeId="", startTime = "", endTime = "", boardroomId = "", content= "", remark = "", isSigned = "", signedType = "";
      var isCycle="",cycleType="",cycleEndTime="",intervalDate="",repetitiveWeek="",repetitiveMonth="", isSync="";
      for (var i = 0; i < mainTblData.length; i++) {
        if(mainTblData[i].key == "is_sync"){
          isSync = mainTblData[i].value;
        }else if(mainTblData[i].key == "name"){
          name = mainTblData[i].value;
        }else if(mainTblData[i].key == "meeting_type_id"){
          meetingTypeId = mainTblData[i].value;
        }else if (mainTblData[i].key == "content") {
          content = mainTblData[i].value;
        }else if (mainTblData[i].key == "remark") {
          remark = mainTblData[i].value;
        }else if (mainTblData[i].key == "start_time") {
          startTime = mainTblData[i].value;
        } else if (mainTblData[i].key == "end_time") {
          endTime = mainTblData[i].value;
        }else if (mainTblData[i].key == "is_cycle") {
          isCycle = mainTblData[i].value;
        }else if (mainTblData[i].key == "cycle_type") {
          cycleType = mainTblData[i].value;
        }else if (mainTblData[i].key == "cycle_end_time") {
          cycleEndTime = mainTblData[i].value;
        }else if (mainTblData[i].key == "interval_date") {
          intervalDate = mainTblData[i].value;
        }else if (mainTblData[i].key == "repetitive_week") {
          repetitiveWeek = mainTblData[i].value;
          //alert("zhaozy:"+repetitiveWeek+"-fix");
        }else if (mainTblData[i].key == "repetitive_month") {
          repetitiveMonth = mainTblData[i].value;
        } else if (mainTblData[i].key == "boardroom_id") {
          boardroomId = mainTblData[i].value;
        } else if (mainTblData[i].key == "emcee_user") {
          if(type == "0"){
            if(param.emceeUser==null || param.emceeUser=="" || param.emceeUser==undefined){
              param.emceeUser = mainTblData[i].value;
            }
            var realValue = mainTblData[i].realValue;
            if(realValue!="" && realValue!=null && realValue!=undefined){
              mainTblData[i].value = realValue;
            }else{
              mainTblData[i].value = "";
            }
          }
        } else if (mainTblData[i].key == "memo_user") {
          if(type == "0"){
            if(param.memoUser==null || param.memoUser=="" || param.memoUser==undefined){
              param.memoUser = mainTblData[i].value;
            }
            var realValue = mainTblData[i].realValue;
            if(realValue!="" && realValue!=null && realValue!=undefined){
              mainTblData[i].value = realValue;
            }else{
              mainTblData[i].value = "";
            }
          }
        } else if (mainTblData[i].key == "attend_user") {
          if(type == "0"){
            if(param.attendUser==null || param.attendUser=="" || param.attendUser==undefined){
              param.attendUser = mainTblData[i].value;
            }
            var realValue = mainTblData[i].realValue;
            if(realValue!="" && realValue!=null && realValue!=undefined){
              mainTblData[i].value = realValue;
            }else{
              mainTblData[i].value = "";
            }
          }
        }else if (mainTblData[i].key == "meeting_attendants") {
          if(type == "0"){
            if(param.attendants==null || param.attendants=="" || param.attendants==undefined){
              param.attendants = mainTblData[i].value;
            }
            var realValue = mainTblData[i].realValue;
            if(realValue!="" && realValue!=null && realValue!=undefined){
              mainTblData[i].value = realValue;
            }else{
              mainTblData[i].value = "";
            }
          }
        }else if (mainTblData[i].key == "is_signed") {
          isSigned = mainTblData[i].value;
        }else if (mainTblData[i].key == "signed_type") {
          signedType = mainTblData[i].value;
        }
      }
      //var nowDateTime = (new Date()).getTime();
      //if (nowDateTime > new Date(startTime).getTime()) {
      var nowDateTime = new Date().format("yyyy-MM-dd HH:mm");
      //需求如果当前是代办状态，开始时间大于当前时间允许通过
      if (nowDateTime > startTime && param.isStart) {
        failureFuc('开始时间需大于当前时间');
         return false;
      }
      //if (new Date(endTime).getTime() <= new Date(startTime).getTime()) {
        if ( endTime <= startTime ) {
        failureFuc('开始时间需小于结束时间');
        return false;
      }
      
      var cycleValue = "";
      if(isCycle == "1"){
        if(cycleType == "0"){
          if(intervalDate == null || intervalDate == ""){
            failureFuc("间隔天数不能为空");
            return false;
          }else if(intervalDate.lehgth > 3){
            failureFuc("间隔天数不能大于3位数");
            return false;
          }
          cycleValue = intervalDate;
        }else if(cycleType == "1"){
          if(repetitiveWeek == null || repetitiveWeek == ""){
            failureFuc("请选择重复星期");
            return false;
          }
          cycleValue = repetitiveWeek;
        }else if(cycleType == "2"){
          if(repetitiveMonth == null || repetitiveMonth == ""){
            failureFuc("请选择重复日期");
            return false;
          }
          cycleValue = repetitiveMonth;
        }
        if(cycleEndTime == null || cycleEndTime == ""){
          failureFuc("周期结束日期不能为空");
          return false;
        }
        let meetingStartTime = new Date(startTime);
        if(new Date(meetingStartTime.getFullYear() + "-" + (meetingStartTime.getMonth() + 1) + "-" + meetingStartTime.getDate()).getTime() > new Date(cycleEndTime).getTime()){
          failureFuc("周期结束日期要不小于会议开始日期");
          return false;
        }
        for (var i = 0; i < mainTblData.length; i++) {
          if(mainTblData[i].key == "cycle_value"){
            mainTblData[i].value = cycleValue;
          }
        }
      }
      if(isSync == '1'){
        if(name==""){
          failureFuc("会议名称不能为空");
          return false;
        }
        if(name!="" && !(/^([\u4E00-\u9FA5]|\w|\.)+$/).test(name)){
          failureFuc("会议名称为中文/字母/数字/下划线/点");
          return false;
        }
        if(name!="" && name!=null && name.length>20){
          failureFuc("会议名称不能超过20个字符");
          return false;
        }
        if(!meetingTypeId){
          failureFuc("请选择会议类型");
          return false;
        }
        if(content != null && isEmojiCharacter(content)){
          failureFuc("会议内容不支持表情输入");
          return false;
        }
        if(content!="" && content!=null && content.length>200){
          failureFuc("会议内容不能超过200字符");
          return 200;
        }
        if(type == "0"){
          // if(param.emceeUser==null || param.emceeUser=="" || param.emceeUser==undefined){
          //   failureFuc("主持人不能为空");
          //   return false;
          // }
          var subTblData = formData.subTbl[0].subTblData;
          var flag = true;
          if(subTblData!=null && subTblData!=undefined && subTblData.length>0){
            for(var i=0; i<subTblData.length; i++){
              var ntblData = subTblData[i];
              var tblFlag = true;
              for(var j=0; j<ntblData.length; j++){
                if(isSigned=="1" && (signedType=="1" || signedType=="2")){
                  if(ntblData[j].key=="signed_address" && (ntblData[j].value==null || ntblData[j].value=="")){
                    tblFlag = false;
                    break;
                  }
                }else{
                  if(ntblData[j].key == "longitude" || ntblData[j].key == "latitude"){
                    if(ntblData[j].value==null || ntblData[j].value==""){
                      ntblData[j].value = "0";
                    }
                  }
                }
              }
              if(!tblFlag){
                flag = false;
                break;
              }
              subTblData[i] = ntblData;
            }
          }
          if(!flag){
            failureFuc("签到地址不能为空");
            return false;
          }
        }
        if(remark != null && isEmojiCharacter(remark)){
          failureFuc("备注不支持表情输入");
          return false;
        }
        if(remark!="" && remark!=null && remark.length > 200){
          failureFuc("备注不能超过200字符");
          return false;
        }
      }else{//清空会议相关信息
        for (var i = 0; i < mainTblData.length; i++) {
          if(mainTblData[i].key == "name" || mainTblData[i].key == "remark" || mainTblData[i].key == "content" || mainTblData[i].key == "emcee_user" 
            || mainTblData[i].key == "attend_user" || mainTblData[i].key == "meeting_attendants" || mainTblData[i].key == "memo_user" || mainTblData[i].key == "meeting_type_id"
            || mainTblData[i].key == "message_push"|| mainTblData[i].key == "file_id"){
            mainTblData[i].value = "";
          }else if(mainTblData[i].key == "meeting_way" || mainTblData[i].key == "is_notice" || mainTblData[i].key == "is_signed"|| mainTblData[i].key == "signed_type"){
            mainTblData[i].value = "0";
          }else if(mainTblData[i].key == "signed_time"){
            mainTblData[i].value = "10";
          }else if(mainTblData[i].key == "notice_time"){
            mainTblData[i].value = "5";
          }else if(mainTblData[i].key == "signed_range"){
            mainTblData[i].value = "100";
          }
        }
      }
      var params = {id: id, boardroomId: boardroomId, startTime: startTime, endTime: endTime, isCycle:isCycle, cycleType:cycleType, cycleValue:cycleValue, cycleEndTime:cycleEndTime};
      DB.SomeModuleAPI.validateMeetingTime(params).then((content) => {
        if (content.type == "0") {
          failureFuc(content.msg);
          return false;
        }else{
          sucessFunc(param)
        }
      }).catch((error) => {
        console.error(error);
      });
    }else{
      sucessFunc(param);
    }
  },
  //操作回调：param:{type:0-驳回到起点,1-正常结束,2-非正常结束,3-发起人撤销,4-正常发起,5-草稿箱,6-通过时保存表单,dataId:dataId}
  operateCallBack:function(param, stateParam){
    var params = {};
    if(param.type == "4" || param.type == "1" || param.type=="6" || param.type=="5"){
      params = {
        jsonStrEmceeUser: stateParam.emceeUser,
        jsonStrMemoUser: stateParam.memoUser,
        jsonStrAttendUser: stateParam.attendUser,
        jsonStrAttendants: stateParam.attendants,
        id: param.dataId,
        status: param.type
      };
      DB.SomeModuleAPI.saveInfoAfterBpm(params).then((content) => {
      }).catch((error) => {
      });
    }else{
      params = {
        applyRecordId: param.dataId,
        status: param.type
      };
      DB.SomeModuleAPI.changeByStatusBpm(params).then((content) => {
      }).catch((error) => {
      });
    }
  },
  //分发收文
  sendToReceive:function(param){
    location.hash = 'document/sendUnit/' + param.formId + "/" + param.dataId;
  },
  dealwithReturnData:function(itemCode,value,sucessFunc){
    if(itemCode == "signed_address"){
      itemCode = ["signed_address", "longitude", "latitude"];
      var reValue = value;
      value = [reValue.name, reValue.longitude, reValue.latitude];
    }
    sucessFunc(itemCode,value);
  },
  messagePushSwitchOption:function(form){
    if(form.itemCode=="message_push"){
      let multiItems = [];
      let messagePushSW = form.messagePushSW;
      if(messagePushSW.indexOf("email") > -1) {
          multiItems.push({value: 'email', name: '邮件' });
      }
      if(messagePushSW.indexOf("mobile") > -1) {
          multiItems.push({value: 'mobile', name: '移动端' });
      }
      if(messagePushSW.indexOf("sms") > -1) {
          multiItems.push({value: 'sms', name: '短信' });
      }
      form.multiItems = multiItems;
    }
    return form;
  },
  dealwithCommonFormParam:function(param, obj){
    var data = obj.props.data;
    var mainTblData = [];
    if(data!=null && data!=undefined && data!="") {
      mainTblData = data.mainTblData;
    }
    //初始化签到方式和会议方式
    if(param.key=="meeting_way"){
      //会议方式
      
      let meetingWays=[];
      if(data.meetingWayStr!=""){
        meetingWays=eval('(' + data.meetingWayStr + ')');
      }
      param.selectOptions=meetingWays;
      let meetingWayValue=param.value;
      if(meetingWayValue){
        let meetingWay={};
        for(let i=0;i<meetingWays.length;i++){
          if(meetingWays[i].value==meetingWayValue.value){
            meetingWay=meetingWays[i];
            break;
          }
        }
        if(Object.getOwnPropertyNames(meetingWay).length==0 && meetingWays.length>0){
          param.value=meetingWays[0];
        }else 
        param.value=meetingWay;
      }else if(meetingWays.length>0){
        param.value=meetingWays[0];
      } 
      
    }
    if(param.key=="signed_type"){
      //签到方式
      let signedTypes=[];
      if(data.signedTypeStr!=""){
        signedTypes=eval('(' + data.signedTypeStr + ')');
      }
      param.selectOptions=signedTypes;
      let signedTypeValue=param.value;
      if(signedTypeValue){
        let signedType={};
        for(let i=0;i<signedTypes.length;i++){
          if(signedTypes[i].value==signedTypeValue.value){
            signedType=signedTypes[i];
            break;
          }
        }
        if(Object.getOwnPropertyNames(signedType).length==0 && signedTypes.length>0){
          param.value=signedTypes[0];
        }else 
        param.value=signedType;
      }else if(signedTypes.length>0){
        param.value=signedTypes[0];
      }
  
    }
    //alert(JSON.stringify(mainTblData));
    let isSync = "1";//默认开启
    let isSigned0= "0",isNotice0="0";
    for(var i=0; i<mainTblData.length; i++){
      if(mainTblData[i].key=="is_sync") {
        isSync = mainTblData[i].value;
        if(param.uniqueName=="oa_meeting_apply_record_is_sync" && isSync==1){
          param.value=true;
        }
        
      }
      if(mainTblData[i].key=="is_signed"){
        isSigned0 = mainTblData[i].value;
      }
      if(mainTblData[i].key=="is_notice"){
        isNotice0 = mainTblData[i].value;
      }
    }
    // 同步会议通知开关没开，隐藏会议信息相关字段
    if(isSync == "0" && (param.key == "name" || param.key == "remark" || param.key == "content" || param.key == "emcee_user" || param.key == "attend_user" || param.key == "meeting_attendants"
      || param.key == "memo_user" || param.key == "meeting_type_id" || param.key == "message_push" || param.key == "meeting_way" || param.key == "file_id"
      || param.key == "is_signed" || param.key == "signed_type" || param.key == "signed_time" || param.key == "signed_range" || param.key == "is_notice"
      || param.key == "notice_time" || param.key == "oa_meeting_signed_addr"|| param.key == "is_sync_calendar")){
      param.isHidden = true;
    }else if(isSync == 1 && (param.key == "name" || param.key == "remark" || param.key == "content" || param.key == "emcee_user" || param.key == "attend_user" || param.key == "meeting_attendants"
      || param.key == "memo_user" || param.key == "meeting_type_id" || param.key == "message_push" || param.key == "meeting_way" || param.key == "file_id"
      || param.key == "is_signed" || param.key == "signed_type" || param.key == "signed_time" || param.key == "signed_range" || param.key == "is_notice"
      || param.key == "notice_time" || param.key == "oa_meeting_signed_addr"|| param.key == "is_sync_calendar")){
       if( param.key == "signed_type" || param.key == "signed_time" || param.key == "signed_range" ||param.key == "notice_time" || param.key == "oa_meeting_signed_addr"){
        if(isSigned0==1 &&(param.key == "signed_type" || param.key == "signed_time" || param.key == "signed_range"||param.key == "oa_meeting_signed_addr")){
          param.isHidden = false;
        }else if(isNotice0==1 &&(param.key == "notice_time" )){
          param.isHidden = false;
        }else 
        param.isHidden = true;
       }else
        param.isHidden = false;

    }
    if(param.key=="boardroom_id" || param.key=="apply_user_name" || param.key=="apply_org_name"){//会议室、申请人和申请部门只读
      param.readOnly = true;
    }else if(param.key == "name" || param.key == "meeting_type_id"){
      param.required = true;
    }else if(param.key=="longitude" || param.key=="latitude"){
      param.isHidden = true;
    }else if(param.key=="emcee_user" || param.key=="memo_user"){
      param.itemType = 'popuser';
      param.checkType = 'radio';
      param.code = 'user';
      param.scopeTable = 'oa_meeting_apply_record_scope';
      param.fieldTable = 'oa_meeting_apply_record';
      param.fieldData = param.key;
      param.showType = 'list';
      // if(param.key == "emcee_user"){
      //   param.required = true;
      // }
    }else if(param.key == "attend_user"){
      param.itemType = 'popuser';
      param.checkType = 'checkbox';
      param.code = 'user,org';
      param.scopeTable = 'oa_meeting_apply_record_scope';
      param.fieldTable = 'oa_meeting_apply_record';
      param.fieldData = param.key;
      param.showType = 'list';
    }else if(param.key == "meeting_attendants"){
      param.itemType = 'popuser';
      param.checkType = 'checkbox';
      param.code = 'user,org';
      param.scopeTable = 'oa_meeting_apply_record_scope';
      param.fieldTable = 'oa_meeting_apply_record';
      param.fieldData = param.key;
      param.showType = 'list';
    }
    if(param.key=="cycle_value"){
      param.isHidden = true;
    }else if(param.key=="cycle_type" || param.key=="cycle_end_time" || param.key=="interval_date"|| param.key=="repetitive_week"|| param.key=="repetitive_month"){
      if(param.key=="cycle_end_time") param.required = true;
      if(mainTblData){
        let isCycleVal = '', cycleTypeValue = '';
        for(var i=0; i<mainTblData.length; i++){
          if(mainTblData[i].key=="is_cycle"){
            isCycleVal = mainTblData[i].value;
          }else if(mainTblData[i].key=="cycle_type"){
            cycleTypeValue = mainTblData[i].value;
          }    
        }
        if(isCycleVal == '0'){
          param.isHidden = true;
          if(param.key=="interval_date") param.required = true;
        }else if(isCycleVal == '1'){
          if(cycleTypeValue == '0'){
            if(param.key=="interval_date") param.required = true;
            else if(param.key=="repetitive_week"|| param.key=="repetitive_month") param.isHidden = true;
          }else if(cycleTypeValue == '1'){
            if(param.key=="repetitive_week") param.required = true;
            else if(param.key=="interval_date"|| param.key=="repetitive_month") param.isHidden = true;
          }else if(cycleTypeValue == '2'){
            if(param.key=="repetitive_month") param.required = true;
            else if(param.key=="interval_date"|| param.key=="repetitive_week") param.isHidden = true;
          }
        }
      }
    }else if(param.key=="message_push" && param.selectOptions.length == 0){
      param.isHidden = true;
    }else if(param.key=="signed_time" || param.key=="signed_type"){
      if(mainTblData){
        for(var i=0; i<mainTblData.length; i++){
          if(mainTblData[i].key=="is_signed" && (mainTblData[i].value=="" || mainTblData[i].value=="0")){
            param.isHidden = true;
          }
        }
      }
    }else if(param.key == "notice_time"){
      if(mainTblData){
        for(var i=0; i<mainTblData.length; i++){
          if(mainTblData[i].key=="is_notice" && (mainTblData[i].value=="" || mainTblData[i].value=="0")){
            param.isHidden = true;
            break;
          }
        }
      }
    }else if(param.key=="signed_range"){
      if(mainTblData){
        var isSigned = "", signedType = "";
        for(var i=0; i<mainTblData.length; i++){
          if(mainTblData[i].key=="is_signed") {
            isSigned = mainTblData[i].value;
          }else if(mainTblData[i].key=="signed_type"){
            signedType = mainTblData[i].value;
          }
        }
        if(isSigned=="1" && (signedType=="1" || signedType=="2")){
          param.isHidden = false;
        }else{
          param.isHidden = true;
        }
      }
    }else if(param.key == "signed_address"){
      param.itemType = 'positioning';
      param.canShowLocate = false;
      if(param.value!="" && param.value!=null){
        var mapAddress = {};
        for(var i=0; i<mainTblData.length; i++){
          if(mainTblData[i].key=="signed_address") {
            mapAddress.name = mainTblData[i].value;
          }else if(mainTblData[i].key=="longitude"){
            mapAddress.longitude = mainTblData[i].value;
          }else if(mainTblData[i].key=="latitude"){
            mapAddress.latitude = mainTblData[i].value;
          }
        }
        param.value = mapAddress;
      }
    }else if(param.key == "oa_meeting_signed_addr"){
      param.isCopy = false;
      if(mainTblData){
        var isSigned = "", signedType = "";
        for(var i=0; i<mainTblData.length; i++){
          if(mainTblData[i].key=="is_signed") {
            isSigned = mainTblData[i].value;
          }else if(mainTblData[i].key=="signed_type"){
            signedType = mainTblData[i].value;
          }
        }
        if(isSigned=="1" && (signedType=="1" || signedType=="2")){
          param.isHidden = false;
        }else{
          param.isHidden = true;
        }
      }
    }
    return param;
  },
  dealwithFormItemChange:function(itemParam,obj){
    var param = [];
    var data = obj.props.data;
    var mainTblData = [];
    if(data!=null && data!=undefined && data!="") {
      mainTblData = data.mainTblData;
    }
    let _isNotice = '', _isSigned = '', _signedType = '';
    for(var i=0; i<mainTblData.length; i++){
      if(mainTblData[i].key=="is_notice") _isNotice = mainTblData[i].value;
      if(mainTblData[i].key=="is_signed") _isSigned = mainTblData[i].value;
      if(mainTblData[i].key=="signed_type") _signedType = mainTblData[i].value;
    }
    if(itemParam.key == "is_sync"){
      let showParam = [{'key': 'isHidden', 'value': false}];
      let hiddenParam = [{'key': 'isHidden', 'value': true}];
      if(itemParam.value == "1"){//同步会议通知开启
        param = showParam;
        if(_isNotice == '1') obj.refs.oa_meeting_apply_record_notice_time.reloadItemParam(param);
        else obj.refs.oa_meeting_apply_record_notice_time.reloadItemParam(hiddenParam);
        if(_isSigned == '1') {
          obj.refs.oa_meeting_apply_record_signed_type.reloadItemParam(param);
          obj.refs.oa_meeting_apply_record_signed_time.reloadItemParam(param);
          if(_signedType != '0'){
            obj.refs.oa_meeting_apply_record_signed_range.reloadItemParam(param);
            obj.refs.sub_oa_meeting_signed_addr.reloadItemParam(param);
          }
        } else {
          obj.refs.oa_meeting_apply_record_signed_type.reloadItemParam(hiddenParam);
          obj.refs.oa_meeting_apply_record_signed_time.reloadItemParam(hiddenParam);
          obj.refs.oa_meeting_apply_record_signed_range.reloadItemParam(hiddenParam);
          obj.refs.sub_oa_meeting_signed_addr.reloadItemParam(hiddenParam);
        }
      }else{//同步会议通知关闭
        param = hiddenParam;
        obj.refs.oa_meeting_apply_record_notice_time.reloadItemParam(hiddenParam);
        obj.refs.oa_meeting_apply_record_signed_type.reloadItemParam(hiddenParam);
        obj.refs.oa_meeting_apply_record_signed_time.reloadItemParam(hiddenParam);
        obj.refs.oa_meeting_apply_record_signed_range.reloadItemParam(hiddenParam);
        obj.refs.sub_oa_meeting_signed_addr.reloadItemParam(hiddenParam);
        obj.refs.oa_meeting_apply_record_is_sync_calendar.reloadItemParam(hiddenParam);
      }
      obj.refs.oa_meeting_apply_record_name.reloadItemParam(param);
      obj.refs.oa_meeting_apply_record_remark.reloadItemParam(param);
      obj.refs.oa_meeting_apply_record_content.reloadItemParam(param);
      obj.refs.oa_meeting_apply_record_emcee_user.reloadItemParam(param);
      obj.refs.oa_meeting_apply_record_attend_user.reloadItemParam(param);
      obj.refs.oa_meeting_apply_record_meeting_attendants.reloadItemParam(param);
      obj.refs.oa_meeting_apply_record_memo_user.reloadItemParam(param);
      obj.refs.oa_meeting_apply_record_meeting_type_id.reloadItemParam(param);
      obj.refs.oa_meeting_apply_record_message_push.reloadItemParam(param);
      obj.refs.oa_meeting_apply_record_meeting_way.reloadItemParam(param);
      obj.refs.oa_meeting_apply_record_file_id.reloadItemParam(param);
      obj.refs.oa_meeting_apply_record_is_signed.reloadItemParam(param);
      obj.refs.oa_meeting_apply_record_is_notice.reloadItemParam(param);
      obj.refs.oa_meeting_apply_record_is_sync_calendar.reloadItemParam(param);
    }
    if(itemParam.key == "is_cycle"){
      if(itemParam.value){
        param = [{'key': 'isHidden', 'value': false},{'key': 'required', 'value': true}];
        for(var i=0; i<mainTblData.length; i++){
          if(mainTblData[i].key=="cycle_type"){
            if(mainTblData[i].value == '0')
              obj.refs.oa_meeting_apply_record_interval_date.reloadItemParam(param);
            if(mainTblData[i].value == '1')
              obj.refs.oa_meeting_apply_record_repetitive_week.reloadItemParam(param);
            if(mainTblData[i].value == '2')
              obj.refs.oa_meeting_apply_record_repetitive_month.reloadItemParam(param);
            break;
          }
        }
      }else{
        param = [{'key': 'isHidden', 'value': true},{'key': 'required', 'value': false}];
        obj.refs.oa_meeting_apply_record_interval_date.reloadItemParam(param);
        obj.refs.oa_meeting_apply_record_repetitive_week.reloadItemParam(param);
        obj.refs.oa_meeting_apply_record_repetitive_month.reloadItemParam(param);
      }
      obj.refs.oa_meeting_apply_record_cycle_type.reloadItemParam(param);
      obj.refs.oa_meeting_apply_record_cycle_end_time.reloadItemParam(param);
    }else if(itemParam.key == "cycle_type"){
      var paramDate = [{'key': 'isHidden', 'value': true},{'key': 'required', 'value': false}];
      var paramWeek = [{'key': 'isHidden', 'value': true},{'key': 'required', 'value': false}];
      var paramMonth = [{'key': 'isHidden', 'value': true},{'key': 'required', 'value': false}];
      if(itemParam.value.value == "0"){
        paramDate = [{'key': 'isHidden', 'value': false},{'key': 'required', 'value': true},{'key': 'value', 'value': ''}];
      }else if(itemParam.value.value == "1"){
        paramWeek = [{'key': 'isHidden', 'value': false},{'key': 'required', 'value': true}];
      }else if(itemParam.value.value == "2"){
        paramMonth = [{'key': 'isHidden', 'value': false},{'key': 'required', 'value': true}];
      }
      obj.refs.oa_meeting_apply_record_interval_date.reloadItemParam(paramDate);
      obj.refs.oa_meeting_apply_record_repetitive_week.reloadItemParam(paramWeek);
      obj.refs.oa_meeting_apply_record_repetitive_month.reloadItemParam(paramMonth);
    }else if(itemParam.key == "is_notice"){
      if(itemParam.value){
        param = [{'key': 'isHidden', 'value': false}];
      }else{
        param = [{'key': 'isHidden', 'value': true}];
      }
      obj.refs.oa_meeting_apply_record_notice_time.reloadItemParam(param);
    }else if(itemParam.key == "is_signed"){
      var tParam = [];
      if(itemParam.value){
        param = [{'key': 'isHidden', 'value': false}];
        var typeParam = obj.refs.oa_meeting_apply_record_signed_type.getItemParam();
        var typeValue = typeParam.value;
        if(typeValue!="" && typeValue!=null && typeValue!=undefined){
          if(typeValue.value=="1" || typeValue.value=="2"){
            tParam = [{'key': 'isHidden', 'value': false}];
          }else{
            tParam = [{'key': 'isHidden', 'value': true}]
          }
        }
      }else{
        param = [{'key': 'isHidden', 'value': true}];
        tParam = [{'key': 'isHidden', 'value': true}]
      }
      obj.refs.oa_meeting_apply_record_signed_type.reloadItemParam(param);
      obj.refs.oa_meeting_apply_record_signed_time.reloadItemParam(param);
      obj.refs.oa_meeting_apply_record_signed_range.reloadItemParam(tParam);
      obj.refs.sub_oa_meeting_signed_addr.reloadItemParam(tParam);
    }else if(itemParam.key == "signed_type"){
      var value = itemParam.value;
      if(value!=null && value!="" && value!=undefined){
        var signedType = value.value;
        if(signedType=="1" || signedType=="2"){
          param = [{'key': 'isHidden', 'value': false}];
        }else{
          param = [{'key': 'isHidden', 'value': true}];
        }
        obj.refs.oa_meeting_apply_record_signed_range.reloadItemParam(param);
        obj.refs.sub_oa_meeting_signed_addr.reloadItemParam(param);
      }
    }
  },
  dealwithTitle:function(props){
    var result = "会议详情";
    if(props.params.dataId == "-1"){
      result = "发起会议";
    }
    return result;
  }
}
